package com.hundsun.yr.universal.p2p.presenter.impl;

import android.content.Context;
import android.text.TextUtils;
import android.util.Log;

import com.hundsun.mobile.zwgt.R;
import com.hundsun.yr.universal.library.data.HSSharedPreferences;
import com.hundsun.yr.universal.library.eventbus.EventCenter;
import com.hundsun.yr.universal.library.netstatus.NetUtils;
import com.hundsun.yr.universal.library.utils.MathUtils;
import com.hundsun.yr.universal.library.widget.HSToast;
import com.hundsun.yr.universal.p2p.AdSlideSuccessBeen;
import com.hundsun.yr.universal.p2p.bean.AdSlideBeen;
import com.hundsun.yr.universal.p2p.bean.AliasTagBean;
import com.hundsun.yr.universal.p2p.bean.AuthListBean;
import com.hundsun.yr.universal.p2p.bean.AuthorizationDetailBean;
import com.hundsun.yr.universal.p2p.bean.AutoBidAuthBean;
import com.hundsun.yr.universal.p2p.bean.AutoBidInfoBean;
import com.hundsun.yr.universal.p2p.bean.BankAccountBeen;
import com.hundsun.yr.universal.p2p.bean.ListOfCashBean;
import com.hundsun.yr.universal.p2p.bean.LoginBeen;
import com.hundsun.yr.universal.p2p.bean.ManeBean;
import com.hundsun.yr.universal.p2p.bean.MessageSettingBean;
import com.hundsun.yr.universal.p2p.bean.MineInvestProtocolBean;
import com.hundsun.yr.universal.p2p.bean.NewsSlideShowBean;
import com.hundsun.yr.universal.p2p.bean.ProductBeen;
import com.hundsun.yr.universal.p2p.bean.StatisticsBean;
import com.hundsun.yr.universal.p2p.bean.UpdateJxPhone;
import com.hundsun.yr.universal.p2p.bean.UpdatePayPwdBeen;
import com.hundsun.yr.universal.p2p.bean.UserInfo;
import com.hundsun.yr.universal.p2p.config.Config;
import com.hundsun.yr.universal.p2p.config.Constants;
import com.hundsun.yr.universal.p2p.config.Container;
import com.hundsun.yr.universal.p2p.config.TaskConstants;
import com.hundsun.yr.universal.p2p.interactor.impl.StringRequestGetInteractorImpl;
import com.hundsun.yr.universal.p2p.interactor.impl.StringRequestInteractorImpl;
import com.hundsun.yr.universal.p2p.listener.BaseMultiLoadedListener;
import com.hundsun.yr.universal.p2p.presenter.base.RequestPresenter;
import com.hundsun.yr.universal.p2p.utils.AndroidDes3Util;
import com.hundsun.yr.universal.p2p.utils.CommTool;
import com.hundsun.yr.universal.p2p.utils.GsonTool;
import com.hundsun.yr.universal.p2p.utils.Logs;
import com.hundsun.yr.universal.p2p.view.base.InitializeView;

import org.json.JSONObject;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.TimeZone;

import de.greenrobot.event.EventBus;


/**
 * @version V1.0
 * @Title: InitializePresenterImpl.java
 * @Description: TODO(用一句话描述该文件做什么)
 * @date 2015-10-27 上午11:18:59
 * @author:hejun.shen
 * @email:shenhj15971@hundsun.com
 * @replace author:
 * @replace date:
 */
public class InitializePresenterImpl implements RequestPresenter, BaseMultiLoadedListener<String> {

    private Context mContext = null;
    private InitializeView mView = null;
    private StringRequestGetInteractorImpl mInteractor = null;
    private StringRequestInteractorImpl mInteractorPost = null;
    /**
     * 用户临时信息sp文件
     **/
    private HSSharedPreferences mConfigSP = null;
    /**
     * 用户信息sp文件
     **/
    private HSSharedPreferences sharedPreferences = null;

    public InitializePresenterImpl(Context context, InitializeView view) {
        // TODO Auto-generated constructor stub
        if (null == view) {
            throw new IllegalArgumentException("Constructor's parameters must not be Null");
        }
        this.mContext = context;
        this.mView = view;
        this.mInteractor = new StringRequestGetInteractorImpl(this);
        this.mInteractorPost = new StringRequestInteractorImpl(this);
        this.mConfigSP = new HSSharedPreferences(mContext, Config.SPPath.file_configInfo);
        this.sharedPreferences = new HSSharedPreferences(mContext, Config.SPPath.file_userLoginedInfo);
    }

    @Override
    public void onSuccess(String task_name, int event_tag, String data) throws Exception {
        try {
            AdSlideBeen adSlideBeen = (AdSlideBeen) GsonTool.getInstanceByJson(AdSlideBeen.class, data);
            if (adSlideBeen.code.equals(Constants.REQUESTCODE_100600)) {
                sharedPreferences.putBoolean(UserInfo.ISLOGIN, false);
                EventBus.getDefault().post(new EventCenter(Constants.EVENT_DATA_LOGIN_EXPIRED));
            }

            Logs.e("xushunzhen: " + task_name + ",adSlideBeen.code" + adSlideBeen.code + ",adSlideBeen.msg" + adSlideBeen.msg);

            switch (task_name) {
                case TaskConstants.TASK_ADSLIDESHOW://广告条
                    switch (adSlideBeen.code) {
                        case Constants.REQUESTCODE_000000:
                            //对data进行解密
                            try {
                                String decode;
                                if (sharedPreferences.getBoolean(UserInfo.ISLOGIN)) {
                                    decode = AndroidDes3Util.decode(adSlideBeen.data, sharedPreferences.getShareProf(UserInfo.TOKENID).substring(0, 24), (Date.parse(adSlideBeen.timestamp) + "").substring((Date.parse(adSlideBeen.timestamp) + "").length() - 8, (Date.parse(adSlideBeen.timestamp) + "").length()));
                                } else {
                                    decode = AndroidDes3Util.decode(adSlideBeen.data, mConfigSP.getShareProf(TaskConstants.TASK_CONFIG), (Date.parse(adSlideBeen.timestamp) + "").substring((Date.parse(adSlideBeen.timestamp) + "").length() - 8, (Date.parse(adSlideBeen.timestamp) + "").length()));
                                }

                                String[] split = decode.split("\\n");
                                //解密成功，循环写入json数组中
                                ArrayList<AdSlideSuccessBeen> adSlideSuccessBeens = GsonTool.jsonToArrayList(split[1], AdSlideSuccessBeen.class);
                                //获取到been对象数组，通知view层
                                this.mView.initializeViews(task_name, adSlideSuccessBeens);
                            } catch (Exception e) {
                                new HSToast(mContext).showToast(mContext.getString(R.string.date_error));
                                e.printStackTrace();
                            }
                            break;
                        case Constants.REQUESTCODE_100600:

                            break;
                        case Constants.REQUESTCODE_100010:

                            break;

                        case Constants.REQUESTCODE_100020:
                            break;
                        default:
                            mView.initializeViews(task_name, null);
                            new HSToast(mContext).getSingleLongToast(adSlideBeen.msg).show();
                            break;
                    }
                    break;
                case TaskConstants.TASK_GOODSLIST:
                    //精选产品
                    switch (adSlideBeen.code) {
                        case Constants.REQUESTCODE_000000:
                            try {
                                String decode2;
                                if (sharedPreferences.getBoolean(UserInfo.ISLOGIN)) {
                                    decode2 = AndroidDes3Util.decode(adSlideBeen.data, sharedPreferences.getShareProf(UserInfo.TOKENID).substring(0, 24), (Date.parse(adSlideBeen.timestamp) + "").substring((Date.parse(adSlideBeen.timestamp) + "").length() - 8, (Date.parse(adSlideBeen.timestamp) + "").length()));
                                } else {
                                    decode2 = AndroidDes3Util.decode(adSlideBeen.data, mConfigSP.getShareProf(TaskConstants.TASK_CONFIG), (Date.parse(adSlideBeen.timestamp) + "").substring((Date.parse(adSlideBeen.timestamp) + "").length() - 8, (Date.parse(adSlideBeen.timestamp) + "").length()));
                                }
                                String[] split2 = decode2.split("\\n");
                                ArrayList<ProductBeen> productBeens = GsonTool.jsonToArrayList(split2[1], ProductBeen.class);
                                if (productBeens.size() > 0) {
                                    this.mView.initializeViews(task_name, productBeens);
                                } else {
                                    this.mView.initializeViews(task_name, null);
                                }
                                Container.getInstance().setSystemTime(System.currentTimeMillis() + "");
                            } catch (Exception e) {
                                e.printStackTrace();
                                this.mView.initializeViews(task_name, null);
                                new HSToast(mContext).showToast(mContext.getString(R.string.date_error));
                            }
                            break;

                        case Constants.REQUESTCODE_100600:
                            new HSToast(mContext).getSingleLongToast(adSlideBeen.msg).show();
                            sharedPreferences.putBoolean(UserInfo.ISLOGIN, false);
                            CommTool.goToLogin(mContext);
                            this.mView.initializeError(task_name, null);
                            EventBus.getDefault().post(new EventCenter(Constants.EVENT_DATA_LOGIN_EXPIRED));
                            break;
                        case Constants.REQUESTCODE_100020:
                            this.mView.initializeError(task_name, null);
                            break;
                        case Constants.REQUESTCODE_100010:
                            this.mView.initializeError(task_name, null);
                            break;
                        default:
                            mView.initializeError(task_name, null);
                            new HSToast(mContext).getSingleLongToast(adSlideBeen.msg).show();
                            break;
                    }

                case TaskConstants.TASK_THREE_GOODS:
                    //精选产品
                    switch (adSlideBeen.code) {
                        case Constants.REQUESTCODE_000000:
                            try {
                                String decode2;
                                if (sharedPreferences.getBoolean(UserInfo.ISLOGIN)) {
                                    decode2 = AndroidDes3Util.decode(adSlideBeen.data, sharedPreferences.getShareProf(UserInfo.TOKENID).substring(0, 24), (Date.parse(adSlideBeen.timestamp) + "").substring((Date.parse(adSlideBeen.timestamp) + "").length() - 8, (Date.parse(adSlideBeen.timestamp) + "").length()));
                                } else {
                                    decode2 = AndroidDes3Util.decode(adSlideBeen.data, mConfigSP.getShareProf(TaskConstants.TASK_CONFIG), (Date.parse(adSlideBeen.timestamp) + "").substring((Date.parse(adSlideBeen.timestamp) + "").length() - 8, (Date.parse(adSlideBeen.timestamp) + "").length()));
                                }
                                String[] split2 = decode2.split("\\n");

                                ArrayList<ProductBeen> productBeens = GsonTool.jsonToArrayList(split2[1], ProductBeen.class);
                                if (productBeens.size() > 0) {
                                    this.mView.initializeViews(task_name, productBeens);
                                } else {
                                    this.mView.initializeViews(task_name, null);
                                }
                                Container.getInstance().setSystemTime(System.currentTimeMillis() + "");
                            } catch (Exception e) {
                                e.printStackTrace();
                                this.mView.initializeViews(task_name, null);
                                new HSToast(mContext).showToast(mContext.getString(R.string.date_error));
                            }
                            break;

                        case Constants.REQUESTCODE_100600:
                            new HSToast(mContext).getSingleLongToast(adSlideBeen.msg).show();
                            sharedPreferences.putBoolean(UserInfo.ISLOGIN, false);
                            CommTool.goToLogin(mContext);
                            this.mView.initializeError(task_name, null);
                            EventBus.getDefault().post(new EventCenter(Constants.EVENT_DATA_LOGIN_EXPIRED));
                            break;
                        case Constants.REQUESTCODE_100020:
                            this.mView.initializeError(task_name, null);
                            break;
                        case Constants.REQUESTCODE_100010:
                            this.mView.initializeError(task_name, null);
                            break;
                        default:
                            mView.initializeError(task_name, null);
                            new HSToast(mContext).getSingleLongToast(adSlideBeen.msg).show();
                            break;
                    }

                    break;
                case TaskConstants.TASK_WITHDRAW://提现
                    switch (adSlideBeen.code) {
                        case Constants.REQUESTCODE_000000:
                            //请求成功
                            try {
                                String decode3 = AndroidDes3Util.decode(adSlideBeen.data, sharedPreferences.getShareProf(UserInfo.TOKENID).substring(0, 24), (Date.parse(adSlideBeen.timestamp) + "").substring((Date.parse(adSlideBeen.timestamp) + "").length() - 8, (Date.parse(adSlideBeen.timestamp) + "").length()));
                                mView.initializeViews(TaskConstants.TASK_WITHDRAW, decode3.substring(decode3.indexOf("<")));
                            } catch (Exception e) {
                                e.printStackTrace();
                                new HSToast(mContext).showToast(mContext.getString(R.string.date_error));
                            }
                            break;
                        case Constants.REQUESTCODE_100500:
                            //验签错误，提示用户登录过期
                            new HSToast(mContext).getSingleLongToast(mContext.getString(R.string.login_overdue)).show();
                            break;
                        case Constants.REQUESTCODE_100020:
                            break;
                        case Constants.REQUESTCODE_100010:
                            break;

                        default:
                            //请求异常情况
                            new HSToast(mContext).getSingleLongToast(adSlideBeen.msg).show();
                            break;
                    }
                    break;
                case TaskConstants.TASK_SMS_APPLY://发送短信验证码
                    switch (adSlideBeen.code) {
                        case Constants.REQUESTCODE_000000:
                            try {
                                String decode3 = AndroidDes3Util.decode(adSlideBeen.data, sharedPreferences.getShareProf(UserInfo.TOKENID).substring(0, 24), (Date.parse(adSlideBeen.timestamp) + "").substring((Date.parse(adSlideBeen.timestamp) + "").length() - 8, (Date.parse(adSlideBeen.timestamp) + "").length()));
                                String[] split3 = decode3.split("\\n");
                                new HSToast(mContext).getSingleLongToast(R.string.sms_success).show();
                            } catch (Exception e) {
                                e.printStackTrace();
                                new HSToast(mContext).showToast(mContext.getString(R.string.date_error));
                            }
                            break;
                        case Constants.REQUESTCODE_100500:
                            //验签失败
                            new HSToast(mContext).getSingleLongToast(mContext.getString(R.string.login_overdue)).show();
                            break;
                        case Constants.REQUESTCODE_100020:
                            break;
                        case Constants.REQUESTCODE_100010:
                            break;

                        default:
                            //请求异常情况
                            new HSToast(mContext).getSingleLongToast(adSlideBeen.msg).show();
                            break;
                    }
                    break;

                //修改密码
                case TaskConstants.TASK_UPDATEPWD://
                    switch (adSlideBeen.code) {
                        case Constants.REQUESTCODE_000000:
                            try {
                                String decode3 = AndroidDes3Util.decode(adSlideBeen.data, mConfigSP.getShareProf(TaskConstants.TASK_CONFIG), (Date.parse(adSlideBeen.timestamp) + "").substring((Date.parse(adSlideBeen.timestamp) + "").length() - 8, (Date.parse(adSlideBeen.timestamp) + "").length()));
                                String[] split3 = decode3.split("\\n");
                                //返回的数据与LoginBeen基本是一样的，这边直接用loginBeen的数据
                                mView.initializeViews(TaskConstants.TASK_UPDATEPWD, split3[1]);
                            } catch (Exception e) {
                                e.printStackTrace();
                                new HSToast(mContext).showToast(mContext.getString(R.string.date_error));
                            }
                            break;
                        case Constants.REQUESTCODE_100020:
                            break;
                        case Constants.REQUESTCODE_100010:
                            break;
                        default:
                            new HSToast(mContext).showToast(adSlideBeen.msg);
                            break;
                    }
                    break;

                case TaskConstants.TASK_OPENBANKACCOUNTPAGE://实名开户接口
                    switch (adSlideBeen.code) {
                        case Constants.REQUESTCODE_000000:
                            try {
                                String decode3 = AndroidDes3Util.decode(adSlideBeen.data, sharedPreferences.getShareProf(UserInfo.TOKENID).substring(0, 24), (Date.parse(adSlideBeen.timestamp) + "").substring((Date.parse(adSlideBeen.timestamp) + "").length() - 8, (Date.parse(adSlideBeen.timestamp) + "").length()));
                                String[] split3 = decode3.split("\\n");
                                //返回的数据封装到been对象里面
                                Logs.e("xushunzhen: " + decode3);
                                MineInvestProtocolBean openAccountBeen = (MineInvestProtocolBean) GsonTool.getInstanceByJson(MineInvestProtocolBean.class, split3[1]);
                                mView.initializeViews(TaskConstants.TASK_OPENBANKACCOUNTPAGE, openAccountBeen);

                            } catch (Exception e) {
                                e.printStackTrace();
                                new HSToast(mContext).showToast(mContext.getString(R.string.date_error) + e.toString());
                            }
                            break;

                        case Constants.REQUESTCODE_100500:
                            //验签错误重新登录
                            new HSToast(mContext).getSingleLongToast(mContext.getString(R.string.login_overdue)).show();
                            break;
                        case Constants.REQUESTCODE_100020:
                            break;
                        case Constants.REQUESTCODE_100010:
                            break;
                        default:
                            new HSToast(mContext).getSingleLongToast(adSlideBeen.msg).show();
                            break;
                    }
                    break;

                case TaskConstants.TASK_RECHARGEPAGE://充值
                    switch (adSlideBeen.code) {
                        case Constants.REQUESTCODE_000000:
                            try {
                                String decode3 = AndroidDes3Util.decode(adSlideBeen.data, sharedPreferences.getShareProf(UserInfo.TOKENID).substring(0, 24), (Date.parse(adSlideBeen.timestamp) + "").substring((Date.parse(adSlideBeen.timestamp) + "").length() - 8, (Date.parse(adSlideBeen.timestamp) + "").length()));
                                String[] split3 = decode3.split("\\n");
                                MineInvestProtocolBean rechargeBean = (MineInvestProtocolBean) GsonTool.getInstanceByJson(MineInvestProtocolBean.class, split3[1]);
                                mView.initializeViews(TaskConstants.TASK_RECHARGEPAGE, rechargeBean);
                            } catch (Exception e) {
                                e.printStackTrace();
                                new HSToast(mContext).showToast(mContext.getString(R.string.date_error));
                            }

                            break;
                        case Constants.REQUESTCODE_100500:
                            //验签错误重新登录
                            new HSToast(mContext).getSingleLongToast(mContext.getString(R.string.login_overdue)).show();
                            break;
                        case Constants.REQUESTCODE_100020:
                            break;
                        case Constants.REQUESTCODE_100010:
                            break;
                        default:
                            new HSToast(mContext).getSingleLongToast(adSlideBeen.msg).show();
                            break;
                    }
                    break;

                case TaskConstants.TASK_CARDUNBIND:
                    //解绑

                    switch (adSlideBeen.code) {
                        case Constants.REQUESTCODE_000000:
                            try {
                                String decode3 = AndroidDes3Util.decode(adSlideBeen.data, sharedPreferences.getShareProf(UserInfo.TOKENID).substring(0, 24), (Date.parse(adSlideBeen.timestamp) + "").substring((Date.parse(adSlideBeen.timestamp) + "").length() - 8, (Date.parse(adSlideBeen.timestamp) + "").length()));
                                String[] split3 = decode3.split("\\n");
//                                new HSToast(mContext).getSingleLongToast(mContext.getString(R.string.unbindcard_success)).show();
                                MineInvestProtocolBean bean = (MineInvestProtocolBean) GsonTool.getInstanceByJson(MineInvestProtocolBean.class, split3[1]);
                                mView.initializeViews(TaskConstants.TASK_CARDUNBIND, bean);
                            } catch (Exception e) {
                                e.printStackTrace();
                                new HSToast(mContext).showToast(mContext.getString(R.string.date_error));
                            }

                            break;
                        case Constants.REQUESTCODE_100500:
                            //验签错误重新登录
                            new HSToast(mContext).getSingleLongToast(mContext.getString(R.string.login_overdue)).show();
                            break;
//                        case Constants.REQUESTCODE_100020:
//                            break;
//                        case Constants.REQUESTCODE_100010:
//                            break;
                        default:
                            new HSToast(mContext).getSingleLongToast(adSlideBeen.msg).show();
                            break;
                    }
                    break;

                case TaskConstants.TASK_CARDBIND:
                    //绑卡
                    switch (adSlideBeen.code) {
                        case Constants.REQUESTCODE_000000:
                            try {
                                String decode3 = AndroidDes3Util.decode(adSlideBeen.data, sharedPreferences.getShareProf(UserInfo.TOKENID).substring(0, 24), (Date.parse(adSlideBeen.timestamp) + "").substring((Date.parse(adSlideBeen.timestamp) + "").length() - 8, (Date.parse(adSlideBeen.timestamp) + "").length()));
                                String[] split3 = decode3.split("\\n");
                                // new HSToast(mContext).getSingleLongToast(mContext.getString(R.string.bindcard_success)).show();
                                Logs.e("task_cardbind: 77777" + split3[1]);
                                mView.initializeViews(TaskConstants.TASK_CARDBIND, split3[1]);

                            } catch (Exception e) {
                                e.printStackTrace();
                                new HSToast(mContext).showToast(mContext.getString(R.string.date_error));
                            }

                            break;
                        case Constants.REQUESTCODE_100500:
                            //验签错误重新登录
                            new HSToast(mContext).getSingleLongToast(mContext.getString(R.string.login_overdue)).show();
                            break;
                        case Constants.REQUESTCODE_100020:
                            break;
                        case Constants.REQUESTCODE_100010:
                            break;
                        default:
                            new HSToast(mContext).getSingleLongToast(adSlideBeen.msg).show();
                            break;
                    }
                    break;

                case TaskConstants.TASK_SETBANKPWD://设置交易密码
                    switch (adSlideBeen.code) {
                        case Constants.REQUESTCODE_000000:
                            try {
                                String decode3 = AndroidDes3Util.decode(adSlideBeen.data, sharedPreferences.getShareProf(UserInfo.TOKENID).substring(0, 24), (Date.parse(adSlideBeen.timestamp) + "").substring((Date.parse(adSlideBeen.timestamp) + "").length() - 8, (Date.parse(adSlideBeen.timestamp) + "").length()));
                                String[] split3 = decode3.split("\\n");
                                Log.e("SETPSD1", split3[1]);
                                ManeBean mUpdatePayPwdBeen = (ManeBean) GsonTool.getInstanceByJson(ManeBean.class, split3[1]);
                                Log.e("HTMLDATA", mUpdatePayPwdBeen.getData());
                                mView.initializeViews(TaskConstants.TASK_SETBANKPWD, mUpdatePayPwdBeen.getData());
                            } catch (Exception e) {
                                e.printStackTrace();
                                new HSToast(mContext).showToast(mContext.getString(R.string.date_error) + e.toString());
                            }
                            break;
                        case Constants.REQUESTCODE_100500:
                            //验签错误重新登录
                            new HSToast(mContext).getSingleLongToast(mContext.getString(R.string.login_overdue)).show();
                            break;
                        default:
                            new HSToast(mContext).getSingleLongToast(adSlideBeen.msg).show();
                            break;

                    }
                    break;

                case TaskConstants.TASK_RETBANKRETPWD://重置修改交易密码
                    Log.e("SETPSD2", adSlideBeen.toString());
                    switch (adSlideBeen.code) {
                        case Constants.REQUESTCODE_000000:
                            try {
                                String decode3 = AndroidDes3Util.decode(adSlideBeen.data, sharedPreferences.getShareProf(UserInfo.TOKENID).substring(0, 24), (Date.parse(adSlideBeen.timestamp) + "").substring((Date.parse(adSlideBeen.timestamp) + "").length() - 8, (Date.parse(adSlideBeen.timestamp) + "").length()));
                                String[] split3 = decode3.split("\\n");
                                ManeBean mUpdatePayPwdBeen = (ManeBean) GsonTool.getInstanceByJson(ManeBean.class, split3[1]);
                                Log.e("HTMLDATA", mUpdatePayPwdBeen.getData());
                                mView.initializeViews(TaskConstants.TASK_RETBANKRETPWD, mUpdatePayPwdBeen.getData());
                            } catch (Exception e) {
                                e.printStackTrace();
                                new HSToast(mContext).showToast(mContext.getString(R.string.date_error) + e.toString());
                            }
                            break;
                        case Constants.REQUESTCODE_100500:
                            //验签错误重新登录
                            new HSToast(mContext).getSingleLongToast(mContext.getString(R.string.login_overdue)).show();
                            break;
                        case Constants.REQUESTCODE_100020:
                            break;
                        case Constants.REQUESTCODE_100010:
                            break;
                        default:
                            new HSToast(mContext).getSingleLongToast(adSlideBeen.msg).show();
                            break;

                    }
                    break;
                case TaskConstants.TASK_SENDSMS:
                    //解析数据吗
                    switch (adSlideBeen.code) {
                        case Constants.REQUESTCODE_000000:
                        case Constants.REQUESTCODE_400001:
                            try {
                                String decode = AndroidDes3Util.decode(adSlideBeen.data, mConfigSP.getShareProf("config"), (Date.parse(adSlideBeen.timestamp) + "").substring((Date.parse(adSlideBeen.timestamp) + "").length() - 8, (Date.parse(adSlideBeen.timestamp) + "").length()));
                                String[] split = decode.split("\\n");
                                mView.initializeViews(TaskConstants.TASK_SENDSMS, split[1]);
                                new HSToast(mContext).showCustomToast(adSlideBeen.msg);
                            } catch (Exception e) {
                                e.printStackTrace();
                                new HSToast(mContext).showToast(mContext.getString(R.string.date_error));
                            }
                            break;
                        case Constants.REQUESTCODE_100020:
                            break;
                        case Constants.REQUESTCODE_100010:
                            break;
                        default:
                            new HSToast(mContext).showCustomToast(adSlideBeen.msg);
                            break;
                    }
                    break;

                case TaskConstants.TASK_RESETPWD:
                    //解析数据吗
                    switch (adSlideBeen.code) {
                        case Constants.REQUESTCODE_000000:
                            try {
                                String decode3 = AndroidDes3Util.decode(adSlideBeen.data, sharedPreferences.getShareProf(UserInfo.TOKENID).substring(0, 24), (Date.parse(adSlideBeen.timestamp) + "").substring((Date.parse(adSlideBeen.timestamp) + "").length() - 8, (Date.parse(adSlideBeen.timestamp) + "").length()));
                                String[] split3 = decode3.split("\\n");
                                mView.initializeViews(TaskConstants.TASK_RESETPWD, split3[1]);
                                new HSToast(mContext).showCustomToast(adSlideBeen.msg);
                            } catch (Exception e) {
                                e.printStackTrace();
                                new HSToast(mContext).showToast(mContext.getString(R.string.date_error));
                            }
                            break;
                        case Constants.REQUESTCODE_100500:
                            //验签错误重新登录
                            new HSToast(mContext).getSingleLongToast(mContext.getString(R.string.login_overdue)).show();
                            break;
                        case Constants.REQUESTCODE_100020:
                            break;
                        case Constants.REQUESTCODE_100010:
                            break;
                        default:
                            new HSToast(mContext).showCustomToast(adSlideBeen.msg);
                            break;
                    }
                    break;

                case TaskConstants.TASK_LOGINSILENT:
                    //登录的接口
                    //数据请求成功之后对数据进行解密存储等操作
                    switch (adSlideBeen.code) {
                        case Constants.REQUESTCODE_000000:
                            //对data进行解密
                            try {
                                String decode = AndroidDes3Util.decode(adSlideBeen.data, sharedPreferences.getShareProf(UserInfo.TOKENID).substring(0, 24), (Date.parse(adSlideBeen.timestamp) + "").substring((Date.parse(adSlideBeen.timestamp) + "").length() - 8, (Date.parse(adSlideBeen.timestamp) + "").length()));
                                String[] split = decode.split("\\n");
                                //解密成功，循环写入json数组中
                                if (split[1].isEmpty()) {
//                                    new HSToast(mContext).getSingleLongToast(mContext.getString(R.string.login_error)).show();
                                    sharedPreferences.putBoolean(UserInfo.ISLOGIN, false);
                                    return;
                                }

                                LoginBeen loginBeen = (LoginBeen) GsonTool.getInstanceByJson(LoginBeen.class, split[1]);
                                //将获得的数据存起来
                                //存放token
                                if (UserInfo.TOKENID == null || UserInfo.TOKENID.isEmpty()) {
                                    new HSToast(mContext).getSingleLongToast(mContext.getString(R.string.login_error)).show();
                                    return;
                                }
                                sharedPreferences.putShareProf(UserInfo.TOKENID, loginBeen.token);

                                if (UserInfo.USER_NO == null || UserInfo.USER_NO.isEmpty()) {
                                    new HSToast(mContext).getSingleLongToast(mContext.getString(R.string.login_error)).show();
                                    return;
                                }

                                //存放用户id
                                sharedPreferences.putShareProf(UserInfo.USER_NO, loginBeen.user_no);
                                //存放用户手机号
                                sharedPreferences.putShareProf(UserInfo.MOBILE, loginBeen.phone);
                                //存放账号，应该就是手机号
                                sharedPreferences.putShareProf(UserInfo.ACCOUNT, loginBeen.phone);
                                //身份证
                                sharedPreferences.putShareProf(UserInfo.CERT_NO, loginBeen.cert_no);
                                sharedPreferences.putShareProf(UserInfo.REALNAME, loginBeen.true_name);
                                sharedPreferences.putShareProf(UserInfo.LENDER, loginBeen.is_lender);
                                /**
                                 * 保存用户开户状态
                                 */
                                if (loginBeen.depository_bank_no != null && !loginBeen.depository_bank_no.isEmpty()) {
                                    //已开户
                                    sharedPreferences.putShareProf(UserInfo.IF_ACCOUNT, "YES");
                                } else {
                                    //已开户
                                    sharedPreferences.putShareProf(UserInfo.IF_ACCOUNT, "NO");
//                                    new HSToast(mContext).getSingleLongToast(mContext.getString(R.string.open_account)).show();
                                }

                                /**
                                 * 用户是否设置了交易密码
                                 */
                                if (loginBeen.set_paypwd_flag != null && !loginBeen.set_paypwd_flag.isEmpty()) {
                                    if (TextUtils.equals(loginBeen.set_paypwd_flag, "1")) {
                                        //已经设置交易密码
                                        sharedPreferences.putShareProf(UserInfo.IF_PAYPWD, "YES");
                                    } else {
                                        sharedPreferences.putShareProf(UserInfo.IF_PAYPWD, "NO");
                                    }
                                } else {
                                    sharedPreferences.putShareProf(UserInfo.IF_PAYPWD, "NO");
                                }

                                /**
                                 * 保存用户等级
                                 */
                                if (loginBeen.level != null && !loginBeen.level.isEmpty()) {
                                    sharedPreferences.putShareProf(UserInfo.USERLEVEL, loginBeen.level);
                                } else {
                                    sharedPreferences.putShareProf(UserInfo.USERLEVEL, "0");
                                }

                                /**
                                 * 保存用户银行卡手机号
                                 */
                                if (loginBeen.depository_bank_mobile != null && !loginBeen.depository_bank_mobile.isEmpty()) {
                                    sharedPreferences.putShareProf(UserInfo.BANKMOBILE, loginBeen.depository_bank_mobile);
                                } else {
                                    sharedPreferences.putShareProf(UserInfo.BANKMOBILE, "");
                                }

                                /**
                                 * 判断是否老用户
                                 */
                                if (loginBeen.ctime != null && !loginBeen.ctime.isEmpty()) {
                                    //将时间转换成时间戳
                                    SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//24小时制
                                    //      SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd hh-mm-ss");//12小时制
                                    simpleDateFormat.setTimeZone(TimeZone.getTimeZone("GMT+8"));
                                    long time = simpleDateFormat.parse(loginBeen.ctime).getTime();
                                    if (MathUtils.compare(time + "", "1498147200000") <= 0) {
                                        //老用户
                                        sharedPreferences.putBoolean(UserInfo.OLDUSER, true);
                                    } else {
                                        sharedPreferences.putBoolean(UserInfo.OLDUSER, false);
                                    }
                                } else {
                                    sharedPreferences.putBoolean(UserInfo.OLDUSER, false);
                                }

                                if (loginBeen.unread != null && !loginBeen.unread.isEmpty()) {
                                    sharedPreferences.putShareProf(UserInfo.UNREAD, loginBeen.unread);
                                } else {
                                    sharedPreferences.putShareProf(UserInfo.UNREAD, "0");
                                }

                                //保存用户年龄
                                if (loginBeen.old != null && !loginBeen.old.isEmpty()) {
                                    sharedPreferences.putShareProf(UserInfo.OLD, loginBeen.old);
                                } else {
                                    sharedPreferences.putShareProf(UserInfo.OLD, "");
                                }

                                sharedPreferences.putBoolean(UserInfo.ISLOGIN, true);
                                mView.initializeViews(TaskConstants.TASK_LOGINSILENT, split[1]);

//                                EventBus.getDefault().post(new EventCenter(Extras.INVEST_REFRESH));//登陆成功通知某些页面进行数据刷新
                                break;
                            } catch (Exception e) {
//                                new HSToast(mContext).getSingleLongToast(mContext.getString(R.string.login_error)).show();
                            }
                        case Constants.REQUESTCODE_200000:
                            //用户名或者密码错误
                            mView.initializeError(task_name, "");
//                            new HSToast(mContext).showToast(mContext.getString(R.string.loginFail));
                            break;
                        case Constants.REQUESTCODE_100020:
                            mView.initializeError(task_name, "");
                            break;
                        case Constants.REQUESTCODE_100500:
                            mView.initializeError(task_name, "");
                            break;
                        case Constants.REQUESTCODE_100600:
                            mView.initializeError(task_name, "");
//                            sharedPreferences.putBoolean(UserInfo.ISLOGIN, false);
//                            HsApplication.goGesture = true;
//                            HsApplication.isSrcreenOn = false;
                            break;
                        case Constants.REQUESTCODE_100010:
                            mView.initializeError(task_name, "");
                            break;
                        default:
                            mView.initializeError(task_name, "");
                            new HSToast(mContext).showCustomToast(adSlideBeen.msg);
                            break;
                    }
                    break;

                case TaskConstants.TASK_LOCATION://位置信息
                    mView.initializeViews(TaskConstants.TASK_LOCATION, "");
                    break;

                case TaskConstants.TASK_BIDSIGN://自动投标规则
                    switch (adSlideBeen.code) {
                        case Constants.REQUESTCODE_000000:
                            String decode = AndroidDes3Util.decode(adSlideBeen.data, sharedPreferences.getShareProf(UserInfo.TOKENID).substring(0, 24), (Date.parse(adSlideBeen.timestamp) + "").substring((Date.parse(adSlideBeen.timestamp) + "").length() - 8, (Date.parse(adSlideBeen.timestamp) + "").length()));
                            String[] split = decode.split("\\n");

                            mView.initializeViews(TaskConstants.TASK_BIDSIGN, split[1]);
                            break;
                        default:
                            mView.initializeError(TaskConstants.TASK_BIDSIGN, "");
                            new HSToast(mContext).showCustomToast(adSlideBeen.msg);
                            break;
                    }
                    break;
                //身份属性判断
                case TaskConstants.IDENTITY:
                    switch (adSlideBeen.code) {
                        case Constants.REQUESTCODE_000000:
                            String decode = AndroidDes3Util.decode(adSlideBeen.data, sharedPreferences.getShareProf(UserInfo.TOKENID).substring(0, 24), (Date.parse(adSlideBeen.timestamp) + "").substring((Date.parse(adSlideBeen.timestamp) + "").length() - 8, (Date.parse(adSlideBeen.timestamp) + "").length()));
                            String[] split = decode.split("\\n");
                            mView.initializeViews(TaskConstants.IDENTITY, split[1]);
                            break;
                        default:
                            new HSToast(mContext).showCustomToast(adSlideBeen.msg);
                            break;
                    }
                    break;
                case TaskConstants.TASK_AUTOBIDAUTH:
                    switch (adSlideBeen.code) {
                        case Constants.REQUESTCODE_000000:
                            String decode = AndroidDes3Util.decode(adSlideBeen.data, sharedPreferences.getShareProf(UserInfo.TOKENID).substring(0, 24), (Date.parse(adSlideBeen.timestamp) + "").substring((Date.parse(adSlideBeen.timestamp) + "").length() - 8, (Date.parse(adSlideBeen.timestamp) + "").length()));
                            String[] split = decode.split("\\n");
                            AutoBidAuthBean instanceByJson = (AutoBidAuthBean) GsonTool.getInstanceByJson(AutoBidAuthBean.class, split[1]);

                            mView.initializeViews(TaskConstants.TASK_AUTOBIDAUTH, instanceByJson);
                            break;
                        default:
                            new HSToast(mContext).showCustomToast(adSlideBeen.msg);
                            break;
                    }
                    break;

                case TaskConstants.TASK_AUTOBIDINFO://查询投标情况
                    switch (adSlideBeen.code) {
                        case Constants.REQUESTCODE_000000:
                            String decode = AndroidDes3Util.decode(adSlideBeen.data, sharedPreferences.getShareProf(UserInfo.TOKENID).substring(0, 24), (Date.parse(adSlideBeen.timestamp) + "").substring((Date.parse(adSlideBeen.timestamp) + "").length() - 8, (Date.parse(adSlideBeen.timestamp) + "").length()));
                            String[] split = decode.split("\\n");
                            AutoBidInfoBean autoBidInfoBean = (AutoBidInfoBean) GsonTool.getInstanceByJson(AutoBidInfoBean.class, split[1]);
                            mView.initializeViews(TaskConstants.TASK_AUTOBIDINFO, autoBidInfoBean);
                            break;
                        default:
                            new HSToast(mContext).showCustomToast(adSlideBeen.msg);
                            break;
                    }
                    break;
                case TaskConstants.TASK_CHANGEJXPHONE:
                    switch (adSlideBeen.code) {
                        case Constants.REQUESTCODE_000000:
                            String decode = AndroidDes3Util.decode(adSlideBeen.data, sharedPreferences.getShareProf(UserInfo.TOKENID).substring(0, 24), (Date.parse(adSlideBeen.timestamp) + "").substring((Date.parse(adSlideBeen.timestamp) + "").length() - 8, (Date.parse(adSlideBeen.timestamp) + "").length()));
                            String[] split = decode.split("\\n");
                            UpdateJxPhone updateJxPhone = (UpdateJxPhone) GsonTool.getInstanceByJson(UpdateJxPhone.class, split[1]);
                            mView.initializeViews(TaskConstants.TASK_CHANGEJXPHONE, updateJxPhone);
                            break;
                        default:
                            new HSToast(mContext).showCustomToast(adSlideBeen.msg);
                            break;
                    }
                    break;

                case TaskConstants.TASK_BANK_ACCOUNT:
                    //查询托管账户信息
                    switch (adSlideBeen.code) {
                        case Constants.REQUESTCODE_000000:
                            //请求网络成功
                            try {
                                String decode = AndroidDes3Util.decode(adSlideBeen.data, sharedPreferences.getShareProf(UserInfo.TOKENID).substring(0, 24), (Date.parse(adSlideBeen.timestamp) + "").substring((Date.parse(adSlideBeen.timestamp) + "").length() - 8, (Date.parse(adSlideBeen.timestamp) + "").length()));
                                String[] split = decode.split("\\n");
                                //数据解析成功，通知v层
                                BankAccountBeen bankAccountBeen = (BankAccountBeen) GsonTool.getInstanceByJson(BankAccountBeen.class, split[1]);
                                Log.e("ACCOUNTCARD1", "" + adSlideBeen);
                                Log.e("ACCOUNTCARD", "" + bankAccountBeen);
                                mView.initializeViews(task_name, bankAccountBeen);
                            } catch (Exception e) {
//								new HSToast(mContext).getSingleLongToast(mContext.getString(R.string.date_error)).show();
                                e.printStackTrace();
                            }

                            mConfigSP.putBoolean(UserInfo.BANK_ACCOUNT_INTERFACE_SUCCESS, true);
                            break;

                        case Constants.REQUESTCODE_100500:
                            new HSToast(mContext).getSingleLongToast(mContext.getString(R.string.login_overdue)).show();
                            mConfigSP.putBoolean(UserInfo.BANK_ACCOUNT_INTERFACE_SUCCESS, false);
                            break;
                        case Constants.REQUESTCODE_200401:
                            mConfigSP.putBoolean(UserInfo.BANK_ACCOUNT_INTERFACE_SUCCESS, true);
                            break;
                        case Constants.REQUESTCODE_100020:
                            //Header值为空--不做任何提示
                            mConfigSP.putBoolean(UserInfo.BANK_ACCOUNT_INTERFACE_SUCCESS, false);
                            break;
                        case Constants.REQUESTCODE_100600:
                            new HSToast(mContext).getSingleLongToast(adSlideBeen.msg).show();
                            sharedPreferences.putBoolean(UserInfo.ISLOGIN, false);
                            CommTool.goToLogin(mContext);
                            mConfigSP.putBoolean(UserInfo.BANK_ACCOUNT_INTERFACE_SUCCESS, false);
                            break;
                        case Constants.REQUESTCODE_100010:
                            mConfigSP.putBoolean(UserInfo.BANK_ACCOUNT_INTERFACE_SUCCESS, false);
                            break;
                        default:
                            new HSToast(mContext).getSingleLongToast(adSlideBeen.msg).show();
                            mConfigSP.putBoolean(UserInfo.BANK_ACCOUNT_INTERFACE_SUCCESS, false);
                            break;
                    }
                    break;

                case TaskConstants.TASK_NEWSLIDESHOW:
                    //新闻公告
                    switch (adSlideBeen.code) {
                        case Constants.REQUESTCODE_000000:
                            //对data进行解密
                            try {
                                String decode;
//                                if (sharedPreferences.getBoolean(UserInfo.ISLOGIN)){
//                                    decode = AndroidDes3Util.decode(adSlideBeen.data, sharedPreferences.getShareProf(UserInfo.TOKENID).substring(0, 24), (Date.parse(adSlideBeen.timestamp) + "").substring((Date.parse(adSlideBeen.timestamp) + "").length() - 8, (Date.parse(adSlideBeen.timestamp) + "").length()));
//                                } else {
                                decode = AndroidDes3Util.decode(adSlideBeen.data, mConfigSP.getShareProf(TaskConstants.TASK_CONFIG), (Date.parse(adSlideBeen.timestamp) + "").substring((Date.parse(adSlideBeen.timestamp) + "").length() - 8, (Date.parse(adSlideBeen.timestamp) + "").length()));
//                                }

                                String[] split = decode.split("\\n");
                                //解密成功，循环写入json数组中
                                ArrayList<NewsSlideShowBean> newsSlideShowBean = GsonTool.jsonToArrayList(split[1], NewsSlideShowBean.class);
                                //获取到been对象数组，通知view层
                                this.mView.initializeViews(task_name, newsSlideShowBean);
                            } catch (Exception e) {
                                new HSToast(mContext).showToast(mContext.getString(R.string.date_error));
                                e.printStackTrace();
                            }
                            break;
                        case Constants.REQUESTCODE_100600:
                            break;
                        case Constants.REQUESTCODE_100010:
                            break;
                        case Constants.REQUESTCODE_100020:
                            break;
                        default:
                            mView.initializeViews(task_name, null);
                            new HSToast(mContext).getSingleLongToast(adSlideBeen.msg).show();
                            break;
                    }
                    break;

                case TaskConstants.TASK_SIGNIN:
                    switch (adSlideBeen.code) {
                        case Constants.REQUESTCODE_000000:
                            //通知V层
                            try {
                                String decode = AndroidDes3Util.decode(adSlideBeen.data, sharedPreferences.getShareProf(UserInfo.TOKENID).substring(0, 24), (Date.parse(adSlideBeen.timestamp) + "").substring((Date.parse(adSlideBeen.timestamp) + "").length() - 8, (Date.parse(adSlideBeen.timestamp) + "").length()));
                                String[] split = decode.split("\\n");
                                new HSToast(mContext).getSingleLongToast(mContext.getString(R.string.sign_success)).show();
//								Logs.e("split: 11111" + split[1]);
                                mView.initializeViews(TaskConstants.TASK_SIGNIN, adSlideBeen.code);
                            } catch (Exception e) {
                                new HSToast(mContext).getSingleLongToast(mContext.getString(R.string.date_error)).show();
                                e.printStackTrace();
                            }
                            break;
                        case Constants.REQUESTCODE_100500:
//							new HSToast(mContext).getSingleLongToast(mContext.getString(R.string.login_overdue)).show();
                            break;
                        case Constants.REQUESTCODE_100020:
                            break;
                        case Constants.REQUESTCODE_100010:
                            break;
                        case Constants.REQUESTCODE_200709:
                            mView.initializeViews(TaskConstants.TASK_SIGNIN, adSlideBeen.code);
                            break;
                        case Constants.REQUESTCODE_100600:
                            new HSToast(mContext).getSingleLongToast(adSlideBeen.msg).show();
                            sharedPreferences.putBoolean(UserInfo.ISLOGIN, false);
                            EventBus.getDefault().post(new EventCenter(Constants.EVENT_DATA_LOGIN_EXPIRED));
                            break;
                        default:
                            new HSToast(mContext).getSingleLongToast(adSlideBeen.msg).show();
                            break;
                    }
                    break;

                //消息设置状态
                case TaskConstants.TASK_NOTICELIST:
                    switch (adSlideBeen.code) {

                        case Constants.REQUESTCODE_000000:

                            //通知V层
                            try {
                                String decode = AndroidDes3Util.decode(adSlideBeen.data, sharedPreferences.getShareProf(UserInfo.TOKENID).substring(0, 24), (Date.parse(adSlideBeen.timestamp) + "").substring((Date.parse(adSlideBeen.timestamp) + "").length() - 8, (Date.parse(adSlideBeen.timestamp) + "").length()));
                                String[] split = decode.split("\\n");
                                MessageSettingBean messageSettingBean = (MessageSettingBean) GsonTool.getInstanceByJson(MessageSettingBean.class, split[1]);

                                mView.initializeViews(task_name, messageSettingBean);
                            } catch (Exception e) {
                                new HSToast(mContext).getSingleLongToast(mContext.getString(R.string.date_error) + e.toString()).show();
                                e.printStackTrace();
                            }
                            break;
                        case Constants.REQUESTCODE_100600:
                            new HSToast(mContext).getSingleLongToast(adSlideBeen.msg).show();
                            sharedPreferences.putBoolean(UserInfo.ISLOGIN, false);
                            EventBus.getDefault().post(new EventCenter(Constants.EVENT_DATA_LOGIN_EXPIRED));
                            break;
                        default:
                            new HSToast(mContext).getSingleLongToast(adSlideBeen.msg).show();
                            break;
                    }
                    break;

                case TaskConstants.TASK_NOTICESET:
                    switch (adSlideBeen.code) {
                        case Constants.REQUESTCODE_000000:
                            //通知V层
                            try {
                                String decode = AndroidDes3Util.decode(adSlideBeen.data, sharedPreferences.getShareProf(UserInfo.TOKENID).substring(0, 24), (Date.parse(adSlideBeen.timestamp) + "").substring((Date.parse(adSlideBeen.timestamp) + "").length() - 8, (Date.parse(adSlideBeen.timestamp) + "").length()));
                                String[] split = decode.split("\\n");

                                mView.initializeViews(task_name, adSlideBeen.code);
                            } catch (Exception e) {
                                new HSToast(mContext).getSingleLongToast(mContext.getString(R.string.date_error)).show();
                                e.printStackTrace();
                            }
                            break;
                        default:
                            new HSToast(mContext).getSingleLongToast(adSlideBeen.msg).show();
                            break;
                    }
                    break;
                case TaskConstants.TASK_GETPUSHINFO:
                    switch (adSlideBeen.code) {
                        case Constants.REQUESTCODE_000000:
                            //通知V层
                            try {
                                String decode = AndroidDes3Util.decode(adSlideBeen.data, sharedPreferences.getShareProf(UserInfo.TOKENID).substring(0, 24), (Date.parse(adSlideBeen.timestamp) + "").substring((Date.parse(adSlideBeen.timestamp) + "").length() - 8, (Date.parse(adSlideBeen.timestamp) + "").length()));
                                String[] split = decode.split("\\n");
                                AliasTagBean aliasTagBean = (AliasTagBean) GsonTool.getInstanceByJson(AliasTagBean.class, split[1]);

                                mView.initializeViews(task_name, aliasTagBean);
                            } catch (Exception e) {
                                new HSToast(mContext).getSingleLongToast(mContext.getString(R.string.date_error)).show();
                                e.printStackTrace();
                            }
                            break;
                        default:
                            new HSToast(mContext).getSingleLongToast(adSlideBeen.msg).show();
                            break;
                    }
                    break;

                case TaskConstants.TASK_STATISTICS:
                    switch (adSlideBeen.code) {
                        case Constants.REQUESTCODE_000000:
                            //通知V层
                            try {
                                String decode;
                                if (sharedPreferences.getBoolean(UserInfo.ISLOGIN)) {
                                    decode = AndroidDes3Util.decode(adSlideBeen.data, sharedPreferences.getShareProf(UserInfo.TOKENID).substring(0, 24), (Date.parse(adSlideBeen.timestamp) + "").substring((Date.parse(adSlideBeen.timestamp) + "").length() - 8, (Date.parse(adSlideBeen.timestamp) + "").length()));
                                } else {
                                    decode = AndroidDes3Util.decode(adSlideBeen.data, mConfigSP.getShareProf(TaskConstants.TASK_CONFIG), (Date.parse(adSlideBeen.timestamp) + "").substring((Date.parse(adSlideBeen.timestamp) + "").length() - 8, (Date.parse(adSlideBeen.timestamp) + "").length()));
                                }
                                String[] split = decode.split("\\n");
                                StatisticsBean statisticsBean = (StatisticsBean) GsonTool.getInstanceByJson(StatisticsBean.class, split[1]);
//
                                mView.initializeViews(task_name, statisticsBean);
                            } catch (Exception e) {
//                                new HSToast(mContext).getSingleLongToast(mContext.getString(R.string.date_error) + e.toString()).show();
                                e.printStackTrace();
                            }
                            break;
                        default:
                            new HSToast(mContext).getSingleLongToast(adSlideBeen.msg).show();
                            break;
                    }
                    break;

                case TaskConstants.TASK_REPAYAUTHPAGE://还款授权
                    switch (adSlideBeen.code) {
                        case Constants.REQUESTCODE_000000:
                            try {
                                String decode3 = AndroidDes3Util.decode(adSlideBeen.data, sharedPreferences.getShareProf(UserInfo.TOKENID).substring(0, 24), (Date.parse(adSlideBeen.timestamp) + "").substring((Date.parse(adSlideBeen.timestamp) + "").length() - 8, (Date.parse(adSlideBeen.timestamp) + "").length()));
                                String[] split3 = decode3.split("\\n");
                                Logs.e("xushunzhen: " + decode3);
                                MineInvestProtocolBean repayAuthorizationBean = (MineInvestProtocolBean) GsonTool.getInstanceByJson(MineInvestProtocolBean.class, split3[1]);
                                mView.initializeViews(TaskConstants.TASK_REPAYAUTHPAGE, repayAuthorizationBean);
                            } catch (Exception e) {
                                e.printStackTrace();
                                new HSToast(mContext).showToast(mContext.getString(R.string.date_error));
                            }

                            break;
                        case Constants.REQUESTCODE_100500:
                            //验签错误重新登录
                            new HSToast(mContext).getSingleLongToast(mContext.getString(R.string.login_overdue)).show();
                            break;
//                        case Constants.REQUESTCODE_100020:
//                            break;
//                        case Constants.REQUESTCODE_100010:
//                            break;
                        default:
                            new HSToast(mContext).getSingleLongToast(adSlideBeen.msg).show();
                            break;
                    }
                    break;

                case TaskConstants.TASK_PAYMENTAUTHPAGE://缴费授权
                    switch (adSlideBeen.code) {
                        case Constants.REQUESTCODE_000000:
                            try {
                                String decode3 = AndroidDes3Util.decode(adSlideBeen.data, sharedPreferences.getShareProf(UserInfo.TOKENID).substring(0, 24), (Date.parse(adSlideBeen.timestamp) + "").substring((Date.parse(adSlideBeen.timestamp) + "").length() - 8, (Date.parse(adSlideBeen.timestamp) + "").length()));
                                String[] split3 = decode3.split("\\n");
                                Logs.e("xushunzhen123: " + adSlideBeen);
                                Logs.e("xushunzhen1234: " + decode3);
                                MineInvestProtocolBean repayAuthorizationBean = (MineInvestProtocolBean) GsonTool.getInstanceByJson(MineInvestProtocolBean.class, split3[1]);

                                mView.initializeViews(TaskConstants.TASK_PAYMENTAUTHPAGE, repayAuthorizationBean);

                            } catch (Exception e) {
                                e.printStackTrace();
                                new HSToast(mContext).showToast(mContext.getString(R.string.date_error));
                            }
                            break;
                        case Constants.REQUESTCODE_100500:
                            //验签错误重新登录
                            new HSToast(mContext).getSingleLongToast(mContext.getString(R.string.login_overdue)).show();
                            break;
                        default:
                            new HSToast(mContext).getSingleLongToast(adSlideBeen.msg).show();
                            break;
                    }
                    break;

                case TaskConstants.TASK_REPAYAUTHDETAIL://还款授权详情
                    switch (adSlideBeen.code) {
                        case Constants.REQUESTCODE_000000:
                            try {
                                String decode3 = AndroidDes3Util.decode(adSlideBeen.data, sharedPreferences.getShareProf(UserInfo.TOKENID).substring(0, 24), (Date.parse(adSlideBeen.timestamp) + "").substring((Date.parse(adSlideBeen.timestamp) + "").length() - 8, (Date.parse(adSlideBeen.timestamp) + "").length()));
                                String[] split3 = decode3.split("\\n");
                                Logs.e("xushunzhen: " + task_name + "," + decode3);
                                AuthorizationDetailBean authorizationDetailBean = (AuthorizationDetailBean) GsonTool.getInstanceByJson(AuthorizationDetailBean.class, split3[1]);
                                mView.initializeViews(TaskConstants.TASK_REPAYAUTHDETAIL, authorizationDetailBean);
                            } catch (Exception e) {
                                e.printStackTrace();
                                new HSToast(mContext).showToast(mContext.getString(R.string.date_error));
                            }
                            break;
                        case Constants.REQUESTCODE_100500:
                            new HSToast(mContext).getSingleLongToast(mContext.getString(R.string.login_overdue)).show();
                            break;
                        default:
                            new HSToast(mContext).getSingleLongToast(adSlideBeen.msg).show();
                            break;
                    }
                    break;

                case TaskConstants.TASK_PAYMENTAUTHDETAIL://缴费授权详情
                    switch (adSlideBeen.code) {
                        case Constants.REQUESTCODE_000000:
                            try {
                                String decode3 = AndroidDes3Util.decode(adSlideBeen.data, sharedPreferences.getShareProf(UserInfo.TOKENID).substring(0, 24), (Date.parse(adSlideBeen.timestamp) + "").substring((Date.parse(adSlideBeen.timestamp) + "").length() - 8, (Date.parse(adSlideBeen.timestamp) + "").length()));
                                String[] split3 = decode3.split("\\n");
                                Logs.e("xushunzhen: " + task_name + "," + decode3);
                                AuthorizationDetailBean authorizationDetailBean = (AuthorizationDetailBean) GsonTool.getInstanceByJson(AuthorizationDetailBean.class, split3[1]);
                                mView.initializeViews(TaskConstants.TASK_PAYMENTAUTHDETAIL, authorizationDetailBean);
                            } catch (Exception e) {
                                e.printStackTrace();
                                new HSToast(mContext).showToast(mContext.getString(R.string.date_error));
                            }
                            break;
                        case Constants.REQUESTCODE_100500:
                            new HSToast(mContext).getSingleLongToast(mContext.getString(R.string.login_overdue)).show();
                            break;
                        default:
                            mView.initializeViews(TaskConstants.TASK_PAYMENTAUTHDETAIL, adSlideBeen);
                            break;
                    }
                    break;

                case TaskConstants.TASK_REPAYAUTHCANCEL://授权取消
                    switch (adSlideBeen.code) {
                        case Constants.REQUESTCODE_000000:
                            try {
                                String decode3 = AndroidDes3Util.decode(adSlideBeen.data, sharedPreferences.getShareProf(UserInfo.TOKENID).substring(0, 24), (Date.parse(adSlideBeen.timestamp) + "").substring((Date.parse(adSlideBeen.timestamp) + "").length() - 8, (Date.parse(adSlideBeen.timestamp) + "").length()));
                                String[] split3 = decode3.split("\\n");
                                ManeBean mUpdatePayPwdBeen = (ManeBean) GsonTool.getInstanceByJson(ManeBean.class, split3[1]);
                                Logs.e("YWHData: " + split3[1]);
                                mView.initializeViews(TaskConstants.TASK_REPAYAUTHCANCEL, mUpdatePayPwdBeen.getHtml());
                            } catch (Exception e) {
                                e.printStackTrace();
                                new HSToast(mContext).showToast(mContext.getString(R.string.date_error));
                            }

                            break;
                        case Constants.REQUESTCODE_100500:
                            new HSToast(mContext).getSingleLongToast(mContext.getString(R.string.login_overdue)).show();
                            break;
                        default:
                            new HSToast(mContext).getSingleLongToast(adSlideBeen.msg).show();
                            break;
                    }
                    break;

                case TaskConstants.TASK_PAYMENTAUTHCANCEL://授权取消
                    switch (adSlideBeen.code) {
                        case Constants.REQUESTCODE_000000:
                            try {
                                String decode3 = AndroidDes3Util.decode(adSlideBeen.data, sharedPreferences.getShareProf(UserInfo.TOKENID).substring(0, 24), (Date.parse(adSlideBeen.timestamp) + "").substring((Date.parse(adSlideBeen.timestamp) + "").length() - 8, (Date.parse(adSlideBeen.timestamp) + "").length()));
                                String[] split3 = decode3.split("\\n");
                                ManeBean mUpdatePayPwdBeen = (ManeBean) GsonTool.getInstanceByJson(ManeBean.class, split3[1]);
                                Logs.e("YWHData: " + split3[1]);
                                mView.initializeViews(TaskConstants.TASK_PAYMENTAUTHCANCEL, mUpdatePayPwdBeen.getHtml());
                            } catch (Exception e) {
                                e.printStackTrace();
                                new HSToast(mContext).showToast(mContext.getString(R.string.date_error));
                            }

                            break;
                        case Constants.REQUESTCODE_100500:
                            new HSToast(mContext).getSingleLongToast(mContext.getString(R.string.login_overdue)).show();
                            break;
                        default:
                            new HSToast(mContext).getSingleLongToast(adSlideBeen.msg).show();
                            break;
                    }
                    break;

                case TaskConstants.TASK_GETAUTHLIST://授权情况
                    switch (adSlideBeen.code) {
                        case Constants.REQUESTCODE_000000:
                            try {
                                String decode3 = AndroidDes3Util.decode(adSlideBeen.data, sharedPreferences.getShareProf(UserInfo.TOKENID).substring(0, 24), (Date.parse(adSlideBeen.timestamp) + "").substring((Date.parse(adSlideBeen.timestamp) + "").length() - 8, (Date.parse(adSlideBeen.timestamp) + "").length()));
                                String[] split3 = decode3.split("\\n");
                                Logs.e("xushunzhen: " + task_name + "," + split3[1]);
                                AuthListBean authListBean = (AuthListBean) GsonTool.getInstanceByJson(AuthListBean.class, split3[1]);
                                mView.initializeViews(TaskConstants.TASK_GETAUTHLIST, authListBean);
                            } catch (Exception e) {
                                mView.initializeError(TaskConstants.TASK_GETAUTHLIST, "");
                                e.printStackTrace();
                                new HSToast(mContext).showToast(mContext.getString(R.string.date_error));
                            }

                            break;
                        default:
                            new HSToast(mContext).getSingleLongToast(adSlideBeen.msg).show();
                            mView.initializeError(TaskConstants.TASK_GETAUTHLIST, "");
                            break;
                    }
                    break;
                /**
                 * 提现新增加接口
                 */
                case TaskConstants.TASK_NEW_ADD:
                    switch (adSlideBeen.code) {
                        //允许跳转至借款详情页面,
                        case Constants.REQUESTCODE_000000:
                            mView.initializeViews(TaskConstants.TASK_NEW_ADD, adSlideBeen);
                            break;
                        //未进行还款授权
                        case Constants.REQUESTCODE_000001:
                            mView.initializeViews(TaskConstants.TASK_NEW_ADD, adSlideBeen);
                            break;
                        //未进行缴费授权
                        case Constants.REQUESTCODE_000002:
                            mView.initializeViews(TaskConstants.TASK_NEW_ADD, adSlideBeen);
                            break;
                    }
                    break;
                /**
                 提现列表回调
                 *
                 */
                case TaskConstants.TASK_WITHDRAEFEE:
                    switch (adSlideBeen.code) {
                        case Constants.REQUESTCODE_000000:
                            try {
                                String decode3 = AndroidDes3Util.decode(adSlideBeen.data, sharedPreferences.getShareProf(UserInfo.TOKENID).substring(0, 24), (Date.parse(adSlideBeen.timestamp) + "").substring((Date.parse(adSlideBeen.timestamp) + "").length() - 8, (Date.parse(adSlideBeen.timestamp) + "").length()));
                                String[] split3 = decode3.split("\\n");
                                Log.e("LLLLLLLLLL", split3[1]);
                                ListOfCashBean listOfCashBean = (ListOfCashBean) GsonTool.getInstanceByJson(ListOfCashBean.class, split3[1]);
                                mView.initializeViews(TaskConstants.TASK_CARDUNBIND, listOfCashBean);
                                //   Log.e("split", decode3);
                            } catch (Exception e) {
                                e.printStackTrace();
                                new HSToast(mContext).showToast(mContext.getString(R.string.date_error));
                            }
                            break;
                        case Constants.REQUESTCODE_100500:
                            //验签错误，提示用户登录过期
                            new HSToast(mContext).getSingleLongToast(mContext.getString(R.string.login_overdue)).show();
                            CommTool.goToLogin(mContext);
                            break;
                        default:
                            //请求异常情况
                            new HSToast(mContext).getSingleLongToast(adSlideBeen.msg).show();
                            break;
                    }
                    break;
                /*提现回调*/
                case TaskConstants.TASK_NEWWITHDRAW:
                    Logs.e("COOOOOOOO: ", adSlideBeen.code);
                    switch (adSlideBeen.code) {
                        case Constants.REQUESTCODE_000000:
                            try {
                                String decode3 = AndroidDes3Util.decode(adSlideBeen.data, sharedPreferences.getShareProf(UserInfo.TOKENID).substring(0, 24), (Date.parse(adSlideBeen.timestamp) + "").substring((Date.parse(adSlideBeen.timestamp) + "").length() - 8, (Date.parse(adSlideBeen.timestamp) + "").length()));
                                String[] split3 = decode3.split("GMT");
                                //  ListOfCashBean listOfCashBean = (ListOfCashBean) GsonTool.getInstanceByJson(ListOfCashBean.class,"{data:"+split3[1] + "}");
                                mView.initializeViews(TaskConstants.TASK_NEWWITHDRAW, split3[1]);

                                // Log.e("decode3",decode3);
                            } catch (Exception e) {
                                e.printStackTrace();
                                new HSToast(mContext).showToast(mContext.getString(R.string.date_error));
                            }
                            break;
                        case Constants.REQUESTCODE_100600:
                            new HSToast(mContext).showToast(R.string.login_overdue);
                            CommTool.goToLogin(mContext);
                            break;
                        case Constants.REQUESTCODE_100500:
                            //验签错误，提示用户登录过期
                            new HSToast(mContext).getSingleLongToast(mContext.getString(R.string.login_overdue)).show();
                            break;
                        case Constants.REQUESTCODE_000002:
                            mView.initializeViews(TaskConstants.TASK_SIGHJUST, adSlideBeen);
                            break;
                        default:
                            //请求异常情况
                            new HSToast(mContext).getSingleLongToast(adSlideBeen.msg).show();
                            String decode3 = AndroidDes3Util.decode(adSlideBeen.data, sharedPreferences.getShareProf(UserInfo.TOKENID).substring(0, 24), (Date.parse(adSlideBeen.timestamp) + "").substring((Date.parse(adSlideBeen.timestamp) + "").length() - 8, (Date.parse(adSlideBeen.timestamp) + "").length()));
                            Log.e("ddd", decode3);
                            break;
                    }
                    break;
            }
        } catch (Exception e) {
//            new HSToast(mContext).showToast(mContext.getString(R.string.date_error));
        }

        mView.closeProgress();
    }


    @Override
    public void onException(String task_name, String msg) {
        if (!task_name.equals(TaskConstants.TASK_LOCATION)) {
            new HSToast(mContext).showToast(msg);
        }

        mView.initializeError(task_name, "");
        mView.closeProgress();
    }

    @Override
    public void initialized() {
        // TODO Auto-generated method stub
    }

    /**
     * 这个请求只有请求头，没有参数
     *
     * @param task_name      任务名
     * @param url            请求地址
     * @param event_tag      加载事件{@link Constants}}
     * @param params         参数
     * @param isSwipeRefresh 是否刷新
     */
    @Override
    public void loadingData(String task_name, String url, int event_tag, HashMap<String, String> params, boolean isSwipeRefresh) {
        // TODO Auto-generated method stub

        if (NetUtils.isNetworkConnected(mContext)) {
            if (isSwipeRefresh) {
                mView.showProgress("");
            }
            mInteractor.getRequestData(task_name, url, event_tag, params);
        } else {
            new HSToast(mContext).showToast(R.string.common_no_network);
            mView.initializeError(task_name, "");
            mView.closeProgress();
        }
    }

    /**
     * params+header
     *
     * @param task_name
     * @param url
     * @param event_tag
     * @param params
     * @param header
     * @param isSwipeRefresh
     */
//    private void xxx(){
//     loadingData("xxx","xxxx","xxxx",new HashMap<>(),new HashMap<String, String>(),true);
//    }
    @Override
    public void loadingData(String task_name, String url, int event_tag, HashMap<String, String> params, HashMap<String, String> header, boolean isSwipeRefresh) {
        if (NetUtils.isNetworkConnected(mContext)) {
            if (isSwipeRefresh) {
                mView.showProgress("");
            }

            if (TextUtils.equals(task_name, TaskConstants.TASK_CARDUNBIND) || TextUtils.equals(task_name, TaskConstants.TASK_LOCATION) || TextUtils.equals(task_name, TaskConstants.TASK_NEW_ADD)) {
                mInteractorPost.getRequestData(task_name, url, event_tag, params, header);
            } else {
                mInteractor.getRequestData(task_name, url, event_tag, params, header);
            }

        } else {
            new HSToast(mContext).showToast(R.string.common_no_network);
            mView.closeProgress();
            mView.initializeError(task_name, "");
        }
    }

    /***
     * json + header
     *
     * @param task_name
     * @param url
     * @param event_tag
     * @param params
     * @param header
     * @param isSwipeRefresh
     */
    @Override
    public void loadingData(String task_name, String url, int event_tag, JSONObject params, HashMap<String, String> header, boolean isSwipeRefresh) {
        if (NetUtils.isNetworkConnected(mContext)) {
            if (isSwipeRefresh) {
                mView.showProgress("");
            }
            mInteractorPost.getRequestData(task_name, url, event_tag, params, header);
        } else {
            new HSToast(mContext).showToast(R.string.common_no_network);
            mView.closeProgress();
            mView.initializeError(task_name, "");
        }
    }
//    /**
//     * 去掉字符串里面的html代码。<br>
//     * 要求数据要规范，比如大于小于号要配套,否则会被集体误杀。
//     *
//     * @param content 内容
//     * @return 去掉后的内容
//     */
//    public static String stripHtml(String content) {
//        content = content.replaceAll("\\\\n", "");
//        content = content.replaceAll("\\\\", "");
//        content=content.substring(1,content.length());
//        content=content.substring(0,content.length()-1);
//        return content;
//    }
}
